package com.wanglibao.woodtrade.woodtrade.model.impl;

import android.content.Context;

import com.wanglibao.woodtrade.woodtrade.model.User;
import com.wanglibao.woodtrade.woodtrade.model.db.BaseDao;

import java.sql.SQLException;
import java.util.List;

/**
 * Created by lugg on 2016/5/10.
 */
public class UserImpl extends BaseDao<User,String> {
    Context context;

    public UserImpl(Context context) {
        super(context, User.class);
        this.context = context;
    }

    public boolean isLogin(){
        List<User> users = new UserImpl(context).getAll();
        if (users != null && users.size() > 0){
            return true;
        }else {
            return false;
        }
    }

    public User getUser(){
        List<User> users = null;
        try {
            users = dao.queryForAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        if (users != null && users.size() > 0){
            return users.get(0);
        }else{
            return null;
        }
    }
}
